import Vue from 'vue'
import Router from 'vue-router'
import IndexPage from '@/IndexPage'
import NProgress from 'nprogress'
import setupRouter from '@/setup/setupRouter'

Vue.use(Router)

const option = {
  mode:'history',
  routes: [
    {
      path: '*',
      component: () => import('@/components/system/NotFound')
    },{
      path: '/noperm',
      component: () => import('@/components/system/NoPerm')
    },{
      path: '/login',
      component: () => import('@/components/system/Login')
    },{
      path: '/',
      component: IndexPage,
      children:[ setupRouter ]
    }
  ]
};

const router = new Router(option);

router.beforeEach((to,from,next)=>{
    NProgress.start();
    next();
});

router.afterEach(()=>{
  NProgress.done();
})

export default router;
